package com.atguigu.eduservice.controller;


import com.atguigu.commonutils.R;
import com.atguigu.eduservice.entity.subject.OneSubject;
import com.atguigu.eduservice.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author huangqicai
 * @since 2022-10-19
 */
@Api(description="课程分类信息")
@RestController
@RequestMapping("/eduservice/subject")
//原来需要在Controller上面加上@CrossOrigin解决跨域问题，现在gateway已经处理了
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    @ApiOperation("增加课程信息")
    /*添加课程分类*/
    /*获取上传过来的文件，把文件内容读取过来*/
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        /*上传过来的excel文件*/
        subjectService.saveSubject(file,subjectService);
        return R.ok();
    }

    @ApiOperation(value = "查询课程分类列表，实现树形结构")
    @GetMapping("/getAllSubject")
    public R getAllSubject(){
        return subjectService.getAllSubject();
    }

}

